/**
*	插件：表格插件
*	开发者：雨中磐石
*	地址：www.rockoa.com
*	日期：2023-07-19
*/

js.table = {
	alltable:{},
	init:function(){
		importcss('table');
	},
	getobj:function(id){
		return this.alltable[id];
	},
	create:function(cans){
		var me = this;
		var defv = js.applyIf(cans,{
			view:'',
			rand:js.getrand(),
			loadci:0,
			checked:false,
			celleditor:false,
			autoLoad:true,
			fanye:false,
			xuhao:true,
			caozuo:false,
			page:1,
			columns:[],
			pageSize:15,
			height:0,
			autoheight:0,
			urlparams:{},
			showtype:'',
			sort:'',
			cnum:'',
			funitid:'',
			dir:'',
			url:'',
			count:0,
			store:{},
			xiangwidth:500,
			selectColor:'rgba(0,0,0,0.1)',
			data:[],
			rendertr:function(){return ''},
			onitemclick:function(da, index, e){},
			onitemdblclick:function(da, index, e){},  //单击行触发
			onbeforeload:function(){}, //数据加载前触发
			onload:function(){}, //数据加载完成后触发
			ontrdata:function(d){return d},
			onloadbefore:function(){} //数据加载完成后但还没有渲染出来时触发
		});
		for(var i in defv)this[i]=defv[i];
		var rand  = this.rand;
		
		this.init = function(){
			this._init();
			this._create();
			if(this.fanye)this._fanye();
			if(this.autoLoad){
				this._loaddata(1);
			}
			this.resize();
		}
		
		this.setColumns=function(da){
			this.columns = da;
			if(this.caozuo)this.columns.push({text:'',dataIndex:'syscaozuo',renderer:function(v,d,oi){
				if(d.id)return '<button type="button" oi="'+oi+'" temp="caozuomenu_'+rand+'" class="webbtn webbtn-mini webbtn-default">操作<i class="icon-angle-down"></i></button>';
			}});
		}
		
		this.getid	= function(){
			return this.view;
		}
		
		this._init	= function(){
			var at 	= '',heis=0;
			if(this.height>0 && !this.showtype)at='height:'+this.height+'px;';
			this.viewobj	= $('#'+this.view+'');
			js.table.alltable[this.view] = this;
			var s='<div style="position:relative;overflow:auto;'+at+'" id="tablebody_'+rand+'"></div><div id="tablefanye_'+rand+'" style="height:50px;overflow:hidden"></div>';
			this.viewobj.html(s);
			this.bodyobj	= $('#tablebody_'+rand+'');
			if(this.autoheight && !this.showtype)this.bodyobj.scroll(function(){
				me._scrollTopla();
			});
		};
		
		this.resize=function(){
			var hei = 0;
			if(!this.autoheight || this.showtype)return;
			hei = this.viewobj.height();
			if(hei==0)return;
			if(this.fanye)hei = hei-$('#tablefanye_'+rand+'').height()-1;
			this.bodyobj.css('height',''+hei+'px');
		};
		
		this.getheader  = function(bo){
			if(this.showtype=='1')return '<div id="tbody_'+rand+'"></div>';
			var s 	= '',i,d,a=this.columns,len=a.length,attr,hs,o2,w1;
			s+='<table width="100%" class="rock-table">';
			s+='<thead><tr>';
			if(this.xuhao)s+='<th class="rock-table-th" width="35"></th>';
			if(this.checked)s+='<th width="35" class="rock-table-th"><div align="center"><input onclick="js.selall(this, \'tablecheck_'+rand+'\')" type="checkbox"></div></th>';
			for(i=0;i<len;i++){
				d = a[i];
				if(d.hidden)continue;
				attr = '';hs='';
				if(d.width)attr+=' width="'+d.width+'"';
				if(!d.align)d.align='center';
				if(this.sort == d.dataIndex)hs='color:'+maincolor+';';
				if(d.style)hs+=''+d.style+';';
				s+='<th nowrap '+attr+' class="rock-table-th">';
				if(!bo){
					o2 = this.viewobj.find("div[lfields='"+d.dataIndex+"']");
					if(o2 && o2[0]){
						w1 = o2[0].clientWidth;
						hs+='width:'+w1+'px';
					}
				}
				if(hs)hs='style="'+hs+'"';
				s+=' <div align="'+d.align+'" '+hs+' lfields="'+d.dataIndex+'">';
				if(this.celleditor&&d.editor)s+='<i class="icon-pencil"></i>';
				s+=''+d.text+'';
				if(d.sortable){
					s+='&nbsp;';
					if(this.sort == d.dataIndex){
						s+='<i tempsort="'+i+'" lx="'+((this.dir=='desc')?'asc':'desc')+'" class="icon-sort-'+((this.dir=='desc')?'down':'up')+' cursor"></i>';
					}else{
						s+='<i tempsort="'+i+'" lx="desc" class="icon-sort cursor"></i>';
					}
				}
				s+=' </div>';
				s+='</th>';
			}
			s+='</tr></thead>';
			if(bo)s+='<tbody id="tbody_'+rand+'"></tbody>';
			s+='</table>';
			return s;
		};
		this._create	= function(){
			if(!this.fanye)$('#tablefanye_'+rand+'').html('');
			var s = this.getheader(true);
			this.bodyobj.html(s);
			this.showData();
			var obj = this.viewobj;
			this.trobj = obj.find('[dataid]');
			
			this.trobj.click(function(event){
				me._itemclick(this, event);
			});
			this.trobj.dblclick(function(event){
				me._itemdblclick(this, event);
			});
			if(this.celleditor){
				var o = obj.find('td[fields]');
				o.dblclick(function(){
					me._celleditla(this);	
				});
			}
			obj.find('i[tempsort]').click(function(){
				me._clickorder(this);
			});
			
			obj.find("button[temp='caozuomenu_"+rand+"']").click(function(){
				me._caozuochengss(this);
				return false;
			});
			this.resize();
		};
		
		this._scrollTopla= function(){
			var id  = 'headerla_'+rand+'';
			var o   = this.bodyobj;
			if(!get(id)){
				var s = this.getheader(false);
				o.append('<div id="'+id+'" style="position:absolute ;z-index:1;left:0px;top:-1px;width:'+(o.width)+'px;">'+s+'</div>');
				$('#'+id+'').find('i[tempsort]').click(function(){
					me._clickorder(this);
				});
			}
			var top = o.scrollTop();
			var o1 = $('#'+id+'');
			if(top<40){
				o1.remove()
			}else{
				o1.show();
				o1.css({'top':''+top+'px'});
			}
		};
		
		this.showData=function(){
			var j,dlen=this.data.length,s;
			for(j=0;j<dlen;j++){
				s=this.createrows(j);
				$('#tbody_'+rand+'').append(s);
			}
			if(this.autoheight)this._scrollTopla();
		}
		
		
		this.createrows=function(j){
			var a	= this.columns;
			var s 	= '',d,i,len=a.length,val,s1,s2='',s3='',s5='',le,st,ov,j,j1,na,attr,sty='',hs='',dis,trsty='';
			ov	= this.ontrdata(this.data[j]);
			s3 	= this.rendertr(ov, this, j);
			if(ov.isrowhui=='1'){
				trsty='color:#aaaaaa;';
			}
			if(ov.trbgcolor)trsty+='background:'+ov.trbgcolor+';';
			if(ov.trfontcolor)trsty+='color:'+ov.trfontcolor+';';
			if(trsty)trsty='style="'+trsty+'"';
			
			if(this.showtype=='1'){
				s = '<div oi="'+j+'" dataid="'+ov.id+'" '+s3+' '+trsty+' class="rock-table-list">';
			}else{
				s='<tr oi="'+j+'" dataid="'+ov.id+'" '+s3+' '+trsty+'  class="rock-table-tr">';
				if(this.xuhao)s+='<td '+s5+' align="right" width="35" class="rock-table-td">'+(j+1+this.pageSize*(this.page-1))+'</td>';
			}
			
			if(this.checked){
				dis = '';
				if(ov.checkdisabled)dis='disabled';
				if(this.showtype=='1'){
				
				}else{
					s+='<td align="center" width="35" class="rock-table-td"><input oi="'+j+'" name="tablecheck_'+rand+'" '+dis+' value="'+ov.id+'" type="checkbox"></td>';
				}
			}	
			for(i=0;i<len;i++){
				d = a[i];
				if(d.hidden)continue;
				na	= d.dataIndex;
				val = ov[na];
				attr= '';
				sty = '';
				if(isempt(val)){
					val = '';
					this.data[j][na]=val;
				}
				if(d.type == 'checkbox'){
					s1 = '<img height="20" width="20" src="images/checkbox'+val+'.png">';
				}else{
					s1 = val;
				}
				if(typeof(d.renderer)=='function'){
					s3 = d.renderer(val, ov, j);
					if(typeof(s3)=='string')s1=s3;
				}
				s2 = '';
				if(i == 0 && this.tree){
					st = ov.stotal;
					le = ov.level;
					for(j1=1;j1<le;j1++)s2+='<img src="images/white.gif" class="icons">&nbsp; ';
					s2 += '<i class="icon-'+((st>0)?'folder-close-alt':'file-alt')+'"></i>&nbsp;';
				}
				if(this.celleditor &&d.editor)attr+=' fields="'+na+'"';
				if(d.width)attr+=' width="'+d.width+'"';
				if(typeof(d.renderstyle)=='function'){
					s3 = d.renderstyle(val, ov, j);
					if(!isempt(s3))sty+=''+s3+';';
				}
				if(typeof(d.renderattr)=='function'){
					s3 = d.renderattr(val, ov, j);
					if(!isempt(s3))attr+=' '+s3+'';
				}
				if(ov[''+na+'_color'])sty+='color:'+ov[''+na+'_color']+';';
				
				if(this.showtype=='1'){
					s3 = d.text;
					if(s3)s3='<font color="#888888">'+s3+'：</font>';
					s+='<div>'+s3+''+s2+''+s1+'</div>';
				}else{
					s+='<td align="'+d.align+'"  class="rock-table-td" '+attr+' style="'+sty+'" row="'+j+'" cell="'+i+'">'+s2+''+s1+'</td>';
				}
			}
			if(this.showtype=='1'){
				s+='</div>';
			}else{
				s+='</tr>';
			}
			return s;
		}
		
		this._loaddata= function(p){
			if(!this.url || this.bool)return;
			this.loadci++;
			var das = this.urlparams;
			das.loadci = this.loadci;
			if(this.sort)das.sort  = this.sort;
			if(this.dir)das.dir    = this.dir;
			if(this.fanye){
				das.page  = p;
				das.limit = this.pageSize;
			}else{
				das.page  = 1;
				das.limit = 9999;
			}
			this.page = das.page;
			this.loading();
			this.onbeforeload();
			this.bool = true;
			js.ajax.get({
				url:this.url,
				cnum:this.cnum,
				funitid:this.funitid,
				data:das,
				onsuccess:function(ret){
					me.unloading();
					me._loaddataback(ret.data);
				},
				onerror:function(ret){
					me.bodyobj.html('<div style="color:red;padding:10px">'+ret.msg+'</div>');
					js.show.hide();
					me.unloading();
				}
			});
		};
		
		this.initbtn = function(o){
			js.initbtn(o, this.view);
		}
		
		this.setparams=function(can, bo){
			for(var i in can)this.urlparams[i]=can[i];
			if(bo){
				this.page = 1;
				this.reload();
			}
		}
		
		this._loaddataback=function(a){
			this.json  = a;
			this.data  = a.rows;
			this.count = a.totalCount;
			if(a.store)this.store = a.store;
			this.onloadbefore(a);
			this._create();
			this._initfany();
			this.onload(a);
		};
		
		this._clickorder = function(o1){
			if(this.loadci==0)return;
			var o,oi,a,dir,sort;
			o  = $(o1);
			oi = parseFloat(o.attr('tempsort'));
			a  = this.columns[oi];
			sort = a.dataIndex;
			dir  = o.attr('lx');
			this.order(sort, dir);
		};
		
		this.order	= function(a, b){
			if(!a)return;
			if(!b)b='asc';
			this.sort = a;
			this.dir  = b;
			this.reload();
		};
		
		this.loading=function(){
			var o1 = this.viewobj;
			var h  = o1.height()-2,w= o1.width()-2,tobj=o1.offset();
			var t1 = tobj.top+1,l1=tobj.left+1;
			this.unloading();
			s='<div id="modeshow_'+rand+'" style="filter:Alpha(opacity=20);opacity:0.2;height:'+h+'px;width:'+w+'px;overflow:hidden;z-index:3;position:absolute;left:'+l1+'px;top:'+t1+'px;line-height:'+h+'px;background:#000000;color:white" align="center"><i style="height:40px;width:40px" class="rock-loading"></i></div>';
			this.viewobj.append(s);
		};
		this.unloading=function(){
			$('#modeshow_'+rand+'').remove();
			this.bool = false;
		}
		
		this.reload= function(){
			this._loaddata(this.page);
		};
		
		this._itemclick= function(o1, e){
			var o = $(o1);
			if(this.selectColor){
				this.trobj.css('background','');
				o.css('background', this.selectColor);
			}
			var oi = parseFloat(o.attr('oi'));
			var a  = this.data[oi];
			this.changedata = a;
			this.changeid	= a.id;
			this.onitemclick(a, oi, e);
		};
		this._itemdblclick= function(o1, e){
			var o 	= $(o1),oi,lxs,o1,cell,farr,o2;
			oi 	= parseFloat(o.attr('oi'));
			o2  = e.target;
			lxs = o2.nodeName.toLowerCase();
			if(lxs!='td'){
				o2  = e.target.parentNode;
				lxs = o2.nodeName.toLowerCase();
			}
			if(lxs=='td'){
				o1  = $(o2);
				cell= parseFloat(o1.attr('cell'));
				farr= this.columns[cell];
				if(!farr)return;
				if(farr.editor)return;//单元格是编辑就退出
			}
			this.onitemdblclick(this.changedata, oi, e);
		};
		
		this.settishi=function(nr){
			$('#bottomtishi_'+rand+'').html(nr);
		};
		this._fanye= function(){
			var s = '';
			s='<div style="margin-top:10px;display:inline-block;width:100%;"><table width="100%"><tr>'+
				'<td nowrap class="webbtn-group">'+
					'<button id="shouye_'+rand+'" type="button" title="首页" class="webbtn webbtn-default">&laquo;</button>'+
					'<button id="shang_'+rand+'"  title="上一页" type="button" disabled class="webbtn  webbtn-default">&lt;</button>'+
					'<button id="nowye_'+rand+'" type="button" disabled class="webbtn webbtn-default"> 第<span id="pages_'+rand+'">1</span>页/共<span id="maxpage_'+rand+'">0</span>页 <span class="caret"></span></button>'+
					'<button id="next_'+rand+'" type="button" title="下一页" disabled class="webbtn webbtn-default">&gt;</button>'+
					'<button id="lastye_'+rand+'" type="button" title="尾页" disabled class="webbtn webbtn-default">&raquo;</button>'+
					'<button id="refresh_'+rand+'" type="button" title="刷新" class="webbtn webbtn-default"><i class="icon-refresh"></i></button>'+ 
				'</td>'+ 
				'<td style="padding:5px;color:gray;width:100%" id="bottomtishi_'+rand+'">&nbsp;</td>'+
				'<td nowrap>'+
					'<span>共记录<span id="zjilu_'+rand+'">0</span>条</span> &nbsp;'+ 
					'每页<input maxlength="3" onblur="js.number(this)" onfocus="js.focusval=this.value" id="pagesize_'+rand+'" type="number" value="'+this.pageSize+'" style="width:40px;text-align:center;height:30px;font-size:12px;margin:0px 2px" class="input">条&nbsp;'+
				'</td>'+
			'</tr></table></div>';
			if(this.showtype=='1'){
				s='<div align="center" style="color:#aaaaaa;margin-top:5px;">';
				if(this.count==0){
					s+='无记录';
				}else{
					s+='共记录'+this.count+'条</span>';
					s+='&nbsp;第'+this.maxPage+'/'+this.page+'页';
					if(this.page>1)s+='<span id="shang_'+rand+'">&nbsp;上一页</span>';
					if(this.page<this.maxPage)s+='<span id="next_'+rand+'">&nbsp;下一页</span>';
				}
				s+='</div>';
			}

			$('#tablefanye_'+rand+'').html(s);
			$('#shouye_'+rand+'').click(function(){me.firstPage();});
			$('#shang_'+rand+'').click(function(){me.backPage();});
			$('#next_'+rand+'').click(function(){me.nextPage();});
			$('#lastye_'+rand+'').click(function(){me.lastPage();});
			$('#refresh_'+rand+'').click(function(){me.reload();});
		
			if(!this.showtype){
				var o1 = $('#pagesize_'+rand+'');
				o1.blur(function(){me.setpageSize(this.value);});
				o1.keyup(function(e){if(e.keyCode==13)this.blur()});
			}
		}
		
		this._initfany = function(){
			if(!this.fanye)return;
			$('#zjilu_'+rand+'').html(''+this.count+'');
			$('#pages_'+rand+'').html(''+this.page+'');
			this.maxPage	= Math.ceil(this.count/this.pageSize);
			$('#maxpage_'+rand+'').html(''+this.maxPage+'');
			if(this.showtype=='1'){this._fanye();return;}
			
			if(this.showtype)return;
			var bo1=false,bo2=false;
			if(this.maxPage <=1 || this.page<=1){
				bo1 = true;
			}
			get('shouye_'+rand+'').disabled=bo1;
			get('shang_'+rand+'').disabled=bo1;
			
			if(this.maxPage <=1){
				get('nowye_'+rand+'').disabled=true;
			}else{
				get('nowye_'+rand+'').disabled=false;
			}
			
			if(this.maxPage <=1 || this.page>=this.maxPage){
				bo2 = true;
			}
			get('next_'+rand+'').disabled=bo2;
			get('lastye_'+rand+'').disabled=bo2;
		};
		this._next	= function(oi){
			var p = this.page+oi;
			if(p<=0)p=1;
			if(p>=this.maxPage)p=this.maxPage;
			this._loaddata(p);
		};
		this.firstPage = function(){
			this._loaddata(1);
		};
		this.backPage = function(){
			this._next(-1);
		};
		this.nextPage = function(){
			this._next(1);
		};
		this.gotoPage = function(p){
			this._loaddata(p);
		};
		this.lastPage = function(){
			this._loaddata(this.maxPage);
		};
		this.setpageSize = function(p){
			p = parseFloat(p);
			if(p<=0)p=this.pageSize;
			$('#pagesize_'+rand+'').val(''+p+'');
			if(this.pageSize == p)return;
			this.pageSize = p;
			this.page	 = 1;
			this.reload();
		};
		
		this._celleditla = function(o1){
			if(this.bool)return;
			var o 		= $(o1),
				fields  = o.attr('fields'),
				row		= parseFloat(o.attr('row')),
				cell	= parseFloat(o.attr('cell'));
			var a		= this.data[row],i,len,sel,d,da,
				b		= this.columns[cell],
				l		= o.offset(),
				w		= o1.clientWidth,
				h		= o1.clientHeight,
				at		= '',
				v		= a[fields]
				ets		= b.editormsg;
			if(!ets)ets='';	
			if(ets)ets='('+ets+')';	
			$('#edittable_'+rand+'').remove();
			if(b.editorbefore && !b.editorbefore(a))return; //编辑前判断
			if(!b.textmsg)b.textmsg='';
			var s	= '<div id="edittable_'+rand+'" style="position:absolute;z-index:2;left:'+(l.left)+'px;top:'+(l.top+h)+'px">';
			s+='<div class="rock-table-edit">';
			s+='	<div>&nbsp;<b>'+b.text+'</b>'+ets+'：&nbsp;<span id="msgteita_'+rand+'">'+b.textmsg+'</span></div>';
			s+='	<div class="blank10"></div>';
			var wss = 200;
			if(b.editorwidth)wss=b.editorwidth;
			var flx = b.type,attr=b.editorattr;
			if(!flx)flx='text';if(!attr)attr='';
			if(flx=='checkbox'){
				if(v=='1')at='checked';
				s+='<div><label><input type="checkbox" id="inputedit_'+rand+'" '+at+' value="1"> '+b.text+'</label></div>';
			}else if(flx=='textarea'){
				s+='<div><textarea style="width:'+wss+'px;height:100px" '+attr+' id="inputedit_'+rand+'" class="inputs">'+v+'</textarea></div>';
			}else if(flx=='select' || flx=='rockcombo'){
				da= this.getstore(b.store, fields);
				s+='<div><select style="width:'+wss+'px" id="inputedit_'+rand+'" '+attr+' class="select">';
				if(da)for(i=0;i<da.length;i++){
					sel='';if(da[i].value==v||da[i].name==v)sel='selected';
					s+='<option value="'+da[i].value+'" '+sel+'>'+da[i].name+'</option>';
				}
				s+='</select></div>';
			}else if(flx=='date'){	
				s+='<div><input type="text" style="width:'+wss+'px;background:#f1f1f1 url(images/date.png) no-repeat right;cursor:pointer;" id="inputedit_'+rand+'" '+attr+' class="inputs" onclick="js.datechange(this)" readonly value="'+v+'"></div>';
			}else{
				s+='<div><input type="'+flx+'" style="width:'+wss+'px" id="inputedit_'+rand+'" '+attr+' class="input" value="'+v+'"></div>';
			}
			s+='	<div class="blank10"></div>';
			if(b.cellautosave)s+='	<div><a id="inputeditsave_'+rand+'" href="javascript:"><i class="icon-ok"></i> 确定</a >&nbsp;  &nbsp; <a href="javascript:" class="hui" onclick="$(\'#edittable_'+rand+'\').remove()"><i class="icon-remove"></i> 取消</a></div>';
			s+='</div>';
			s+='</div>';
			$('body').append(s);
			var o2 = get('edittable_'+rand+'');
			var jg = l.left + ((w-o2.clientWidth)*0.5);
			if(jg + o2.clientWidth> winWb())jg = winWb() - o2.clientWidth - 5;
			$(o2).css({left:''+jg+'px',top:''+(l.top-o2.clientHeight)+'px'});
			var o3 = get('inputedit_'+rand+'');
			o3.focus();
			$(o3).keyup(function(e){
				if(e.keyCode==13)this.blur();
			});
			var arr = {oldvalue:v,fields:fields,type:b.type,id:a.id,obj:o,row:row}
			if(!b.cellautosave){
				$(o3).blur(function(){
					me._editforcuschen(this, arr, b);
				});
			}else{
				$('#inputeditsave_'+rand+'').click(function(){
					me._editforcuschen(this, arr, b);
				});
			}
		};
		
		this.getstore = function(da, fid){
			if(typeof(da)=='undefined'){
				da = this.store[fid];
			}
			return da;
		}
		
		this._editforcuschen = function(o1, a, farr){
			var o1= get('inputedit_'+rand+'');
			var v = o1.value,ov = a.oldvalue;
			if(a.type=='checkbox')if(!o1.checked)v='0';
			var selv= v+'';
			if(a.type=='select' || a.type=='rockcombo')selv=o1.options[o1.selectedIndex].text;
			if(v==ov || selv==ov){
				$('#edittable_'+rand+'').remove();
				return;
			}
			var vid = 'msgteita_'+rand+'';
			js.setmsg('处理中...','#ff6600',vid);
			o1.disabled = true;
			this.bool = true;
			var data = {id:a.id,fieldname:a.fields,value:v};
			js.ajax.post({
				url:this.urledit,
				cnum:this.cnum,
				funitid:this.funitid,
				data:data,
				onsuccess:function(){
					me.bool=false;
					js.setmsg('处理完成','green',vid);
					$('#edittable_'+rand+'').remove();
					var ohtml = a.obj.html();
					ohtml	  = ohtml.replace(ov, v);
					if(a.type=='checkbox')ohtml='<img height="20" width="20" src="images/checkbox'+v+'.png">';
					if(a.type=='select' || a.type=='rockcombo')ohtml=selv;
					a.obj.html(ohtml);
					me.data[a.row][a.fields] = v;
					if(farr.editorafter)farr.editorafter();//保存后处理
				},
				onerror:function(ret){
					$('#edittable_'+rand+'').remove();
					me.bool=false;
				}
			});
		};
		
		this.getData= function(fid){
			var a = this.data;
			if(fid)a= this.json[fid];
			if(!isNaN(fid))a= this.data[fid];
			return a;
		};
		
		this._caozuochengss=function(o1){
			var oi,d,num,mid,name,o2;
			o2= $(o1);
			oi= parseFloat(o2.attr('oi'));
			d = this.getData(oi);
			num=this.num;
			mid = d.id;
			if(d.modenum)num=d.modenum;
			name=this.name;if(d.modename)name=d.modename;
			js.table.menu({
				obj:o2,num:num,mid:mid,
				name:name,
				cnum:this.cnum,
				funitid:this.funitid,
				xiangwidth:this.xiangwidth,
				data:d,
				table:this
			});
		};
		
		this.del = function(cans){
			var url = this.urldelete;
			if(!url)return;
			js.ajax.get({
				loading:'删除中...',
				url:url,
				cnum:this.cnum,
				funitid:this.funitid,
				data:cans,
				loadsuccess:'删除成功',
				onsuccess:function(ret){
					me.reload();
				}
			});
		}
		
		this.init();
	},
	menu:function(cans){
		importjs('menu','createbill',cans);
	}
}